﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace 小区物业管理系统
{
    public partial class 小区公告管理 : System.Web.UI.Page
    {   
        小区物业管理系统DataContext db = new 小区物业管理系统DataContext();

        protected void Page_Load(object sender, EventArgs e)
        {
            小区物业管理系统DataContext db = new 小区物业管理系统DataContext();
            var res = from r in db.公告
                      select r;
            GridView1.DataSource = res;
            GridView1.DataBind();
        }

      
       

        protected void CheckBox2_CheckedChanged(object sender, EventArgs e)
        {
            
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            公告 公告 = new 公告();
            公告.公告编号 =int.Parse(TextBox1.Text);
            公告.公告标题 = TextBox2.Text;
            公告.公告内容 = TextBox3.Text;
            公告.公告日期= TextBox4.Text;
            公告.发布人 = TextBox5.Text;
            db.公告.InsertOnSubmit(公告);
            db.SubmitChanges();
            Bind();
        }
        protected void Bind()
        {
            var res = from r in db.公告
                      select r;
            GridView1.DataSource = res;
            GridView1.DataBind();
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            var res = from r in db.公告
                      where r.公告编号 == int.Parse(TextBox1.Text)
                      select r;
            db.公告.DeleteAllOnSubmit(res);
            db.SubmitChanges();
            Bind();
        }
    }
}